add option to transform filter to delete creation times (#882)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Tue, 14 Jun 2022 18:13:17 +0000 (12:13 -0600)
committerGitHub <noreply@github.com>
Tue, 14 Jun 2022 18:13:17 +0000 (12:13 -0600)
* add option to transform filter to delete creation times

* document grammar corrections.

reference/filter1.txt
reference/help.txt
transform.cc
transform.h
xmldoc/filters/options/transform-timeless.xml [new file with mode: 0644]

index 2b48ea54e0bae3fc9bada6c811a4886b8f6bac62..9520ab7d19225ce823d9eb5b911e7c0f21860acc 100644 (file)
@@ -111,6 +111,7 @@ option      transform       trk     Transform waypoint(s) or route(s) into tracks(s) [W/R]  stri
 option transform       rptdigits       Number of digits in generated names     integer         2               https://www.gpsbabel.org/WEB_DOC_DIR/filter_transform.html#fmt_transform_o_rptdigits
 option transform       rptname Use source name for route point names   boolean N                       https://www.gpsbabel.org/WEB_DOC_DIR/filter_transform.html#fmt_transform_o_rptname
 option transform       del     Delete source data after transformation boolean N                       https://www.gpsbabel.org/WEB_DOC_DIR/filter_transform.html#fmt_transform_o_del
+option transform       timeless        Create transformed points without times boolean N                       https://www.gpsbabel.org/WEB_DOC_DIR/filter_transform.html#fmt_transform_o_timeless
 validate       Validate internal data structures       https://www.gpsbabel.org/WEB_DOC_DIR/filter_validate.html
 option validate        checkempty      Check for empty input   boolean 0                       https://www.gpsbabel.org/WEB_DOC_DIR/filter_validate.html#fmt_validate_o_checkempty
 option validate        debug   Output debug messages instead of possibly issuing a fatal error boolean 0                       https://www.gpsbabel.org/WEB_DOC_DIR/filter_validate.html#fmt_validate_o_debug
index d3668a30aa7d4b6c7c693cdd20d7e21a71af2827..046d1449d3f33875bc78ec29d1f026393660e6a2 100644 (file)
@@ -584,6 +584,7 @@ Supported data filters:
          rptdigits             Number of digits in generated names 
          rptname               Use source name for route point names 
          del                   Delete source data after transformation 
+         timeless              Create transformed points without times 
        height                Manipulate altitudes                              
          add                   Adds a constant value to every altitude (meter, ap 
          wgs84tomsl            Converts WGS84 ellipsoidal height to orthometric h 
index 93a78aece49b30173132324ca853fe705ad5d47b..62d131828695c2bdf9e6d18573d96928f11ea922 100644 (file)
@@ -49,6 +49,9 @@ void TransformFilter::transform_waypoints()
   foreach (Waypoint* wpt, *global_waypoint_list) {
 
     wpt = new Waypoint(*wpt);
+    if (timeless) {
+      wpt->SetCreationTime(gpsbabel::DateTime());
+    }
     switch (current_target) {
     case 'R':
       route_add_wpt(rte, wpt, RPT, name_digits);
@@ -96,6 +99,9 @@ void TransformFilter::transform_trk_disp_hdr_cb(const route_head* trk)
 void TransformFilter::transform_any_disp_wpt_cb(const Waypoint* wpt)
 {
   auto* temp = new Waypoint(*wpt);
+  if (timeless) {
+    temp->SetCreationTime(gpsbabel::DateTime());
+  }
   if (current_target == 'R') {
     route_add_wpt(current_rte, temp, current_namepart, name_digits);
   } else if (current_target == 'T') {
@@ -127,9 +133,11 @@ void TransformFilter::transform_tracks()
 
 void TransformFilter::process()
 {
-  int delete_after = (opt_delete && (*opt_delete == '1')) ? 1 : 0;
+  timeless = opt_timeless && (*opt_timeless == '1');
+
+  bool delete_after = opt_delete && (*opt_delete == '1');
 
-  use_src_name = (opt_rpt_name && (*opt_rpt_name == '1')) ? 1 : 0;
+  use_src_name = opt_rpt_name && (*opt_rpt_name == '1');
 
   name_digits = 3;
   if (rpt_name_digits && *rpt_name_digits) {
index 717d0f00494f886a5c2686dccb1c414a5b5b75ca..a4cc50559cc744689c39a61caa6851efc8d793a5 100644 (file)
@@ -46,9 +46,12 @@ private:
   route_head* current_rte{};
 
   char* opt_routes{}, *opt_tracks{}, *opt_waypts{}, *opt_delete{}, *rpt_name_digits{}, *opt_rpt_name{};
+  char* opt_timeless{};
+  bool timeless{};
+  bool use_src_name{};
   QString current_namepart;
 
-  int name_digits{}, use_src_name{};
+  int name_digits{};
 
   const QString RPT = "RPT";
 
@@ -77,6 +80,10 @@ private:
       "del", &opt_delete, "Delete source data after transformation", "N",
       ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
     },
+    {
+      "timeless", &opt_timeless, "Create transformed points without times", "N",
+      ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
+    }
   };
 
   void transform_waypoints();
diff --git a/xmldoc/filters/options/transform-timeless.xml b/xmldoc/filters/options/transform-timeless.xml
new file mode 100644 (file)
index 0000000..1af6b6a
--- /dev/null
@@ -0,0 +1,4 @@
+<para>
+This option tells
+GPSBabel to create points without creation times instead of copying the creation time from the source points.
+</para>